#include <iostream>

using namespace std;

typedef enum
{
    Tank_Type_56,
    Tank_Type_96,
    Tank_Type_NUm
}Tank_Type;

class Tank
{
public:
    virtual const string& type()=0;
};

class Tank56 :public Tank
{
public:
    Tank56():Tank(),m_strType("Tank56")
    {
    }

    const string& type() override
    {
        cout<<m_strType.data()<<endl;
        return m_strType;
    }
private:
    string m_strType;
};

class Tank96: public Tank
{
public:
    Tank96():Tank(),m_strType("Tank96")
    {
    }

    const string& type() override
    {
        cout<<m_strType.data()<<endl;
        return m_strType;
    }
private:
    string m_strType;
};

class TankFactory
{
public:
    Tank* createTank(Tank_Type type)
    {
        switch(type)
        {
        case Tank_Type_56:
            return new Tank56();
        case Tank_Type_96:
            return new Tank96();
        default:
            return nullptr;
        }
    }
};

int main()
{
   TankFactory* factory=new TankFactory();
   Tank* tank56=factory->createTank(Tank_Type_56);
   tank56->type();
   Tank* tank96=factory->createTank(Tank_Type_96);
   tank96->type();

   delete tank56;
   tank56=NULL;
   delete tank96;
   tank96=NULL;
   delete factory;
   factory=NULL;

   return 0;
}
